import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      // 启动要显示的界面
      home: HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Evenet使用示例"),
      ),
      body: MyHomeBody(),
    );
  }
}

class MyHomeBody extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Center(
        child: Listener(
          onPointerDown: (event) {
            print('指针按下：$event');
            print('${event.position}');
            print('${event.localPosition}');
          },
          onPointerMove: (event) {
            print('指针移动：$event');
          },
          onPointerUp: (event) {
            print('指针松开：$event');
          },
          onPointerCancel: (event) {
            print('指针打断取消：$event');
          },
          child: Container(
            width: 200,
            height: 200,
            color: Colors.green,
          ),
        )
    );
  }
}
